﻿
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <script src="/Scripts/boot.js?v=$AppVersion" type="text/javascript"></script>
    <script src="/Scripts/PlatForm/ComTools.js?v=$AppVersion" type="text/javascript"></script>
    <script src="/Scripts/PlatForm/SingleForm.js?v=$AppVersion" type="text/javascript"></script>
    <script src="/Form/Init/$Model.data.FormId/$Model.data.FormState/$Model.data.KeyValue"></script>
    <script type="text/javascript" hasvelocity="true">
        var OpenFormId = "$Model.data.OpenFormId"
        var FormId = "$Model.data.FormId"
        var FormState = "$Model.data.FormState"
        var KeyValue = "$Model.data.KeyValue"
        var SingleParams = ""
    </script>
</head>
<body>
    <div class="row-wrap">
        <div class="row  row-hd row-hd-responsive" style="height: 100%">
            <!--end col-md-3-->
            <div class="col-md-12 col-hd-12">
                <div class="mini-splitter" vertical="false" style="width: 100%; height: 100%">
                    <div size="20%" showcollapsebutton="true">
                        <div class="portlet box blue" style="height: 100%">
                            <div class="portlet-title">
                                <div class="captiontools">
                                    <a class="mini-button blue" id="HZ_PremTemplateManage.Add" onclick="PowerForm.OnBtnAdd(this)"><i class="fa fa-plus"></i>新增</a>
                                    <a class="mini-button blue" id="HZ_PremTemplateManage.Del" onclick="PowerForm.OnBtnDel(this,SingleParams)"><i class="fa fa-trash-o"></i>删除</a>
                                    <a class="mini-button blue" id="HZ_PremTemplateManage.Save" onclick="PowerForm.OnBtnSave(this)"><i class="fa fa-save"></i>保存</a>
                                </div>
                            </div>
                            <div class="portlet-body" style="height: 100%">
                                <div id="HZ_PremTemplateManage" class="mini-datagrid" editnextonenterkey="true" visible="true" allowcellselect="true"
                                     checkrecursive="false" idfield="Id" allowcelledit="true" fitcolumns="" style="width: 100%; height: 100%;"
                                     onselectionchanged="onSelectionChanged" onload="onLoad">
                                    <div property="columns">
                                        <div type="indexcolumn" width="20" headeralign="center">序号</div>
                                        <div name="Code" field="Code" headeralign="center" header="编号" width="30" allowsort="true">编号<input property="editor" class="mini-textbox" style="width: 100%;" /></div>
                                        <div field="Title" header="名称" headeralign="center" allowsort="true">名称<input property="editor" class="mini-textbox" style="width: 100%;" /></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div showcollapsebutton="true">
                        <div class="portlet box blue" style="height: 95%">
                            <div class="portlet-title">
                                <div class="captiontools">
                                    <div class="captiontools">
                                        <a class="mini-button blue" id="update"><i class="fa fa-pencil-square-o "></i>编辑</a>
                                        <a class="mini-button blue" id="add"><i class="fa fa-plus"></i>新增节点</a>
                                        <a class="mini-button blue" id="delete"><i class="fa fa-trash-o"></i>清空</a>
                                        <a class="mini-button blue" id="save"><i class="fa fa-save"></i>保存</a>
                                        <!--<a class="mini-button blue" id="saveImg"><i class="fa fa-save"></i>保存为图片</a>-->
                                    </div>
                                </div>
                            </div>
                            <div class="portlet-body" style="height: 100%">
                                <div class="flow">
                                    <!--<div class="flow-header">
                                        <div class="flow-title">流程编辑器</div>
                                    </div>-->
                                    <div class="flow-body">
                                        <div class="flow-menu" style="display:none">
                                            <h5>节点类型列表</h5>
                                            <div id="flow-btns" class="flow-btns">
                                                <div class="flow-btn btn-base" data-type="base"></div>
                                                <div class="flow-btn btn-flow" data-type="flow"></div>
                                                <div class="flow-btn btn-node" data-type="node"></div>
                                                <div class="flow-btn btn-judge" data-type="judge"></div>
                                            </div>
                                        </div>
                                        <div class="flow-container">
                                            <div class="flow-main" id="flow-main"></div>
                                        </div>

                                    </div>
                                </div>
                                <!-- singleform配置需要 -->
                                <div id="HZ_PremTemplateManage_Dtl" class="mini-datagrid" style="height: 100%;display:none" showSummaryRow="true"
                                     idfield="Id" allowresize="true" allowcellselect="true">
                                    <div property="columns">
                                        <div field="DataJson" headeralign="center" name="DataJson">数据<input property="editor" class="mini-textbox" /></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var PowerForm = new SingleForm();
        $(function () {
            PowerForm.Init();
        });
        mini.parse();

        PowerForm.EventAfterDelete = function (e, row) {
            $.ajax({
                url: "/HZStandard/DelPreTasks",
                type: "POST",
                data: {
                    MasterId: row[0].Id,
                    BlockId: ""
                },
                cacha: false,
                async: false,
                success: function (text) {
                    
                }
            });
        }

        function onLoad(e) {
            if (mini.get("HZ_PremTemplateManage").data.length == 0) {
                mini.get("add").disable();
                mini.get("delete").disable();
                mini.get("save").disable();
            }
            if (mini.get("HZ_PremTemplateManage").getSelected() == undefined && mini.get("HZ_PremTemplateManage").data.length > 0) {
                mini.get("HZ_PremTemplateManage").setSelected(mini.get("HZ_PremTemplateManage").getRow(0));
            }
            
        }

        function onSelectionChanged(e) {
            
            var selectedId = e.selected.Id;
            var params = {};
            params.KeyWord = "HZ_PremTemplateManage_Dtl";
            params.KeyWordType = "BO";
            params.select = "";
            params.swhere = " MasterId = '" + selectedId + "' ";
            params.sort = "";
            params.index = 0;
            params.size = 0;
            params.extparams = "";
            $.ajax({
                url: "/Form/GridPageLoad",
                type: "POST",
                data: params,
                async: false,
                success: function (text) {
                    var o = mini.decode(text);
                    var odata = mini.decode(o.data.value);
                    
                    if ($('#flow-main').html() != "") {
                        jsPlumb.reset();
                        $('#flow-main').html("");
                    }
                    main.init();//先执行初始化绑定事件
                    isNew = false;
                    mini.get("add").disable();
                    mini.get("delete").disable();
                    mini.get("save").disable();
                    if (odata == "") {
                        main.draw({ blocks: [], connects: [], lineDescs: [] });
                    } else {
                        main.draw(mini.decode(odata[0].DataJson));
                    }
                }
            });
        }
    </script>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/Projects/Power.PIP.HZ.Standard/scripts/PlatForm/jsPlumb/css/index.css">
    <script src="https://cdn.bootcss.com/jquery/1.12.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.js"></script>
    <script src="https://cdn.bootcss.com/jsPlumb/1.7.6/jquery.jsPlumb.min.js"></script>
    <script src="https://cdn.bootcss.com/html2canvas/0.5.0-beta4/html2canvas.min.js"></script>
    <script src="https://cdn.bootcss.com/canvg/1.5/canvg.min.js"></script>
    <script src="/Projects/Power.PIP.HZ.Standard/scripts/PlatForm/jsPlumb/js/layer/layer.js" type="text/javascript"></script>
    <script src="/Projects/Power.PIP.HZ.Standard/scripts/PlatForm/jsPlumb/js/config.js" type="text/javascript"></script>
    <script src="/Projects/Power.PIP.HZ.Standard/scripts/PlatForm/jsPlumb/js/index.js" type="text/javascript"></script>
</body>
</html>
